﻿<%@ Page Title="Admin Console - Group List" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="GroupList.aspx.cs" Inherits="AdminConsole.Group_List" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <form runat="server">
    <div id="page-content-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h1>Group List</h1>
                    <table id="groupList" border="1" style="margin-top:20px;">
                        <tr>
                            <th>Group ID</th>
                            <th>Group Name</th>
                            <th>User Data</th>
                        </tr>
                    </table> <br />
                    <span id="currentGroup" class="label label-info" style="font-size:18px; padding:16px; margin-top:20px;"></span>
                </div>
            </div>
        </div>
    </div>

    <asp:Button ID="editJson" style="display:none" runat="server" OnClick="editJSON" />

    <input type="hidden" id="subscriptionKey" runat="server" />
    <input type="hidden" id="groupId" runat="server" />

    </form>

    <script type="text/javascript">

        $(document).ready(function () {

            window.onload = function () {
                if (!window.location.hash) {
                    window.location = window.location + '#loaded';
                    window.location.reload();
                }
            }

            getKeys();
            createGroupList();

            $.ajax({
                dataType: 'json',
                contentType: 'application/json',
                url: 'keys.json',
                type: "GET",
                async: false,
                success: function (data) {
                    var keys = data;
                    document.getElementById("<%=subscriptionKey.ClientID %>").value = keys.subscriptionkey;
                    document.getElementById("<%=groupId.ClientID %>").value = keys.groupid;
                    document.getElementById("currentGroup").innerHTML = "Default Group:  " + keys.groupid;
                }
            });
        });

        function setDefaultGroup(groupId) {
            document.getElementById("<%=groupId.ClientID %>").value = groupId;
            document.getElementById("<%=editJson.ClientID %>").click();
        }

    </script>

</asp:Content>
